package com.restcloud.run.PI;

import com.restcloud.pojo.PersonalInformation.*;
import com.restcloud.pojo.Public.Code;
import com.restcloud.pojo.Public.Id;
import com.restcloud.pojo.Public.Value;
import com.restcloud.utils.TimeUtil;
import com.restcloud.utils.XmlUtil;

import java.util.ArrayList;
import java.util.List;

public class Update {

    public static void main(String[] args) {

        MCCI_IN000002UV01 mcci = new MCCI_IN000002UV01();
        mcci.setXmlns("urn:hl7-org:v3");
        mcci.setITSVersion("XML_ 1.0");
        mcci.setXmlnsXsi("http://www.w3.org/2001/XMLSchema-instance");
        mcci.setSchemaLocation("urn:hl7-org:v3 ../multicacheschemas/MCCI_IN000002UV01.xsd");
        /**
         * 消息本身的 ID，需保证 院内唯一性
         */
        mcci.setId(new Id("2.16.156.10011.0","@12122"));
        /**
         * 创建时间
         */
        Value creationTime = new Value(TimeUtil.dateTime());
        mcci.setCreationTime(creationTime);

        Id interactionId = new Id("2.16.840.1.113883.1.6","MCCI_IN000002UV01");
        interactionId.setDisplayable("true");
        mcci.setInteractionId(interactionId);

        mcci.setProcessingCode(new Code("P"));

        mcci.setProcessingModeCode(new Code());

        mcci.setAcceptAckCode(new Code("AL"));

        Receiver receiver = new Receiver();
        receiver.setTypeCode("RCV");
        Device device = new Device();
        device.setClassCode("DEV");
        device.setDeterminerCode("INSTANCE");
        List<Id> idItem1 = new ArrayList<>();
        idItem1.add(new Id("2.16.156.10011.0.1.1","2.16.156.10011.0.1.1"));
        device.setId(idItem1);
        receiver.setDevice(device);
        mcci.setReceiver(receiver);

        Receiver sender = new Receiver();
        sender.setTypeCode("SND");
        Device device1 = new Device();
        device1.setClassCode("DEV");
        device1.setDeterminerCode("INSTANCE");
        List<Id> idItem2 = new ArrayList<>();
        idItem2.add(new Id("2.16.156.10011.0.1.2","2.16.156.10011.0.1.2"));
        device1.setId(idItem2);
        sender.setDevice(device1);
        mcci.setSender(sender);

        Receiver acknowledgement = new Receiver();
        acknowledgement.setTypeCode("AE");
        Value targetMessage = new Value();
        Id tarId =new Id("2.16.156.10011.0","请求的消息 ID");
        targetMessage.setId(tarId);
        acknowledgement.setTargetMessage(targetMessage);
        List<Value> textList = new ArrayList<>();
        textList.add(new Value(new Value("未查询到数据")));
        acknowledgement.setAcknowledgementDetail(textList);
        mcci.setAcknowledgement(acknowledgement);

        String s = XmlUtil.beanToXml(mcci, MCCI_IN000002UV01.class, "GBK");
        System.out.println(s);
    }
}
